<?php

namespace app\frontend\controller;

use app\admin\model\Caser;
use think\Controller;
use think\Db;

class Product extends Controller
{
    public function index()
    {
        $case = new Caser();
        $casies = $case->table('d_goods');
        $cases = $casies->paginate(20);
        $this->assign('cases', $cases);
        echo $this->fetch();
    }
    
    public function details()
    {
        $id = input('id');
        $case = Db::table('d_goods')->where('id',$id)->find();
        $this->assign('case', $case);
        echo $this->fetch();
    }

    public function package()
    {
        $config = $this->getConfig();
        $this->assign('config', $config);
        echo $this->fetch();
    }

    public function getConfig()
    {
        $config = Db::table('d_config')->select();
        $d = [];
        foreach ($config as $v) {
            $d[$v['key']] = $v['value'];
        }
        return $d;
    }
}
